const path = require('path');

//tq3d
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
let cesiumSource = './node_modules/wecesium/Source'
//

module.exports = {
	//tq3d
	configureWebpack: {
		module: {
			unknownContextCritical: /^.\/.*$/,
			unknownContextCritical: false
		},
		performance: {
			hints: false
		},
		output: {
			filename: '[name].js',
			path: path.resolve(__dirname, 'dist'),
			sourcePrefix: ''
		},
		amd: {
			// Enable webpack-friendly use of require in cesium
			toUrlUndefined: true
		},
		node: {
			// Resolve node module use of fs
			fs: 'empty'
		},


		resolve: {
			alias: {
				'vue$': 'vue/dist/vue.esm.js',
				'@': path.resolve('src'),
				'cesium': path.resolve(__dirname, cesiumSource)
			}
		},
		plugins: [
			new CopyWebpackPlugin([
				{from: path.join(cesiumSource, '../Build/Cesium/Assets'), to: 'wecesium/Assets'},
				{from: path.join(cesiumSource, '../Build/Cesium/Widgets'), to: 'wecesium/Widgets'},
				{from: path.join(cesiumSource, '../Build/Cesium/Workers'), to: 'wecesium/Workers'},
				{from: path.join(cesiumSource, '../Build/Cesium/ThirdParty/Workers'), to: 'wecesium/ThirdParty/Workers'},
				{
					from: path.join(cesiumSource, 'ThirdParty/draco_decoder.wasm'),
					to: 'wecesium/ThirdParty/draco_decoder.wasm',
					toType: 'file'
				}
			]),
			new webpack.DefinePlugin({ // 5
				CESIUM_BASE_URL: JSON.stringify('./wecesium')
			})
		]
	},
	//

}
